﻿@model EvertonApp.AdminWeb.Models.ComercioModel

<script type="text/javascript">
    var jQuery = {};
</script>

<center>
<div id="divGridComercios">
    @if (@Model.Comercios != null && @Model.Comercios.Count() > 0)
    {
        WebGrid grid = new WebGrid(defaultSort: "Nombre", rowsPerPage: 8, ajaxUpdateContainerId: "divGridComercios");
        grid.Bind(Model.Comercios, autoSortAndPage: true, rowCount: Model.Comercios.Count());
        @grid.GetHtml(
            fillEmptyRows: false,
            tableStyle: "table table-striped table-bordered table-condensed",
            mode: WebGridPagerModes.All,
            //firstText: "<< Primera",
            //previousText: "< Anterior",
            //nextText: "Siguiente >",
            //lastText: "Última >>",
            columns: new[]{
                //grid.Column("IdComercio",header: "Nº Comercio", canSort: false),
                grid.Column("Nombre",header: "Nombre", canSort: false),
                grid.Column("Direccion",header: "Dirección", canSort: false),
                grid.Column("Telefono",header: "Teléfono", canSort: false), 
                grid.Column("",header: "Acciones", format:@<text>
@*                                                               @Ajax.ActionLink("Ver", "Details", "Comercio2", new { id = item.IdComercio }, new AjaxOptions{  HttpMethod = "GET", UpdateTargetId = "myModal", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup"} )*@
                                                               @Ajax.ActionLink("Eliminar", "Delete", "Comercio2", new { IdComercio = item.IdComercio }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divGridComercios", OnComplete="limpiarCampos();" })
                                                               @Ajax.ActionLink("Editar", "Edit", "Comercio2", new { IdComercio = item.IdComercio, Nombre = item.Nombre, Direccion = item.Direccion, Telefono = item.Telefono }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "myModal", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup();limpiarCampos();"})
                                                                @Ajax.ActionLink("Gestionar Ofertas", "GestionarOfertas", "Comercio2", new { IdComercio = item.IdComercio }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "global"})

                                                           </text> )}
        )
    }
    else
    {
        <label>No se han encontrado comercios.</label>
    }
</div>
</center> 